<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="/page" prefix="public"%>
<public:pageControl classPath="app.portalbs.tools.pwd.PwdEdit"/>
<script>
	function pwPWDTablePanel_afterEvent(panel,page){
		
		var form = page.find("pwPWDTableForm");
		
		form.getJQueryObject("USER_NEW_PLUS").prop("type","password");
		form.hide("USER_NEW_PLUS");
		
		form.getJQueryObject("USER_NEW_PWD").prop("type","password");
		form.getJQueryObject("USER_REL_PWD").prop("type","password");
		
		form.getJQueryObject("USER_NEW_PWD").blur(function(){
			
			var value = form.value("USER_NEW_PWD");
			
			var slevel = checkStrong(value);
			
			if(value == undefined || value == ""){
				form.html("USER_NEW_PWD_HELP", form.ico("glyphicon glyphicon-remove")+" 密码不能为空！  ");
				form.fontColor("USER_NEW_PWD_HELP","#D34A46");
			}
			
			else if(value.length < 8){
				form.html("USER_NEW_PWD_HELP", form.ico("glyphicon glyphicon-remove")+" 密码长度不够  ");
				form.fontColor("USER_NEW_PWD_HELP","#D34A46");
			}
			else if(slevel < 2){
				form.html("USER_NEW_PWD_HELP", form.ico("glyphicon glyphicon-remove")+" 密码强度：弱！请修改！ ");
				form.fontColor("USER_NEW_PWD_HELP","#D34A46");
			}
			
			else if(slevel < 4){
				form.html("USER_NEW_PWD_HELP", form.ico("glyphicon glyphicon glyphicon-warning-sign")+" 密码强度：中！");
				form.fontColor("USER_NEW_PWD_HELP","#ED9C2A");
			}
			
			else{
				form.html("USER_NEW_PWD_HELP", form.ico("glyphicon glyphicon-ok")+" 密码强度：高！");
				form.fontColor("USER_NEW_PWD_HELP","#5AB55A");
			}
			
		});
		
		form.getJQueryObject("USER_REL_PWD").blur(function(){
			
			var value = form.value("USER_NEW_PWD");
			var raleValue = form.value("USER_REL_PWD");
			
			if(value == raleValue){
				form.html("USER_REL_PWD_HELP", form.ico("glyphicon glyphicon-ok")+" ");
				form.fontColor("USER_REL_PWD_HELP","#5AB55A");
			}else{
				form.html("USER_REL_PWD_HELP", form.ico("glyphicon glyphicon-remove")+" 密码不一致，请重输！ ");
				form.fontColor("USER_REL_PWD_HELP","#D34A46");
			}
			
		});
		
	}

	function pwSaves_portal_click(panel,page){
		
		var form = page.find("pwPWDTableForm");
		
		var value = form.value("USER_NEW_PWD");
		var raleValue = form.value("USER_REL_PWD");	
		var slevel = checkStrong(value);
		
		if(value == undefined || value == ""){
			alert("密码不能为空！");
			return;
		}
		
		if(value.length < 8){
			alert("密码长度不够！");
			return;
		}
		
		else if(slevel < 2){
			alert("密码强度：弱！请修改！");
			return;
		}
		
		else if(value != raleValue){
			alert(" 密码不一致，请重输！ ");
			return;
		}
		
		var sendSet = new Yacon.data.DataSet(page);
		
		sendSet.setWhereField("USER_NEW_PWD",Yacon.ens(form.value("USER_NEW_PWD")).encode());
		
		sendSet.switchMessage("resetPWD");
		
		page.windows.closeWindow();
		
	}
	
</script>